import { ref, reactive, computed } from 'vue'
import { defineStore } from 'pinia'
import { getStorage, setStorage, removeStorage } from '@/utils/storage';

export const useTokenStore = defineStore('token', () => {
  const t = getStorage('token') ?? ''
  const token = ref(t)

  const setToken= data => {
    token.value = data
    setStorage('token',  data)
  }

  const clearToken = () => {
    token.value = ''
    removeStorage('token')
  }

  return { token, setToken, clearToken }
})
